package com.codejiwei.flink.sql;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @author jiwei
 * @description
 * @date 2023/5/25 17:35
 */
public class Flink_Table_FileSource {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(10);
        StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);

        // 2.1 表的元数据信息
//        Schema schema = Schema.newBuilder()
//                .column("id", DataTypes.STRING())
//                .column("ts", DataTypes.BIGINT())
//                .column("vc", DataTypes.INT())
//                .build();

        // 2.2 连接文件, 并创建一个临时表, 其实就是一个动态表
//        DataStreamSource<String> sensorStream = env.readTextFile("src/main/resources/data/sensor-data.log");
//        Table table = tableEnv.fromDataStream(sensorStream)
//                .addColumns($("id"), $("ts"), $("vc"))
//                .createTemporalTableFunction();



        env.execute();
    }
}
